# -*- coding: utf-8 -*-
# author: AZJ
# date: 2024/11/14
# 假如命运扼住了你的咽喉，你就去挠她的咯吱窝
import openpyxl
from faker import Faker
import random
# from hongruan.finance_pom.opdata import OpData
'''一、Python编写程序，以实现生成100条不同用户数据，包含Name、Site、Email、PhoneNumber
要求：
（1）Site为不同国家所包含地名
（2）Email后缀为 .cn的git邮箱
   eg：xxxx@git.cn
(3):生成不同国家的电话号码 
（4）：写入excel文件
'''


def write_xl(file, data):
    wb = openpyxl.Workbook()
    ws = wb.active
    for row in range(len(data)):
        for col in range(len(data[row])):
            ws.cell(row=row + 1, column=col + 1).value = data[row][col]
    wb.save(f'{file}.xlsx')

site_list = [
    "ar_EG", "ar_PS", "ar_SA", "bg_BG", "bs_BA", "cs_CZ",
    "de_DE", "dk_DK", "el_GR", "en_AU", "en_CA", "en_GB",
    "en_NZ", "en_US", "es_ES", "es_MX", "et_EE", "fa_IR",
    "fi_FI", "fr_FR", "hi_IN", "hr_HR", "hu_HU", "hy_AM",
    "it_IT", "ja_JP", "ka_GE", "ko_KR", "lt_LT", "lv_LV",
    "ne_NP", "nl_NL", "no_NO", "pl_PL", "pt_BR", "pt_PT",
    "ro_RO", "ru_RU", "sl_SI", "sv_SE", "tr_TR", "uk_UA",
    "zh_CN", "zh_TW"
]
domain = "@git.cn"
list_all = [["Name","Site","Email","PhoneNumber"]]
for i in range(100):
    user = []
    r_int = random.randint(0, len(site_list)-1)
    fake = Faker(locale=site_list[r_int])
    # print()
    address = site_list[r_int] + "---" + fake.address()
    name = fake.name()
    user.append(name)
    user.append(address)
    email = fake.user_name() + domain
    user.append(email)
    phone = fake.phone_number()
    user.append(phone)
    list_all.append(user)
write_xl('user', data=list_all)